//
//  FoundMainViewController.swift
//  DYSwiftFramework
//
//  Created by huangdeyu on 2021/10/20.
//  Copyright © 2021 none. All rights reserved.
//

import Foundation
import UIKit

class FoundMainViewController: BasePageController,RouterControllerMixin {
    
    var navigator:LiveHomeNavigatorView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        print("发现viewDidLoad")
        addChildViewControllers()
        view.backgroundColor = Color.white
        navigator = LiveHomeNavigatorView(titles: ["关注","达人推荐","直播"],visibleIndex: 2)
        view.addSubview(navigator!)
        navigator?.snp.makeConstraints({ (make) in
            make.left.right.top.equalToSuperview()
            make.height.equalTo(NAV_HEIGHT)
        })
        // 点击导航栏
        navigator?.onTap = {[weak self] (last, after) in
            self?.scrollTo(index: after,animated: false)
            self?.navigator?.scrollTo(index: after)
        }
        
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print("发现viewWillAppear")
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        print("发现viewWillDisappear")
    }
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        print("发现viewDidDisappear")
    }
    
    func addChildViewControllers()  {
        let focus = FocusViewController()
        let recommend = RecommendViewController.init()
        let live = LiveViewController.init()
        setup(controllers: [focus,recommend,live], visibleIndex: 2)
    }

    override func onPageChanged(index: Int) {
        self.navigator?.scrollTo(index: index)
    }
}
